//脚本唯一关键字,通过该关键字找到对应脚本，每个脚本必须有该描述。
var v_script_id = 'user_1';
//脚本状态,0:该脚本不许执行，1:该脚本可以执行
var v_status = '1';

//脚本逻辑写在run语句之间
if (run  && action.getAuthority().is(3)){
	
	var user = action.getSession().getAttribute("user");
	action.vars.put(action.V_TABLE_NAME,'h_auth_users');//指定获取数据的表名
	action.vars.put(action.V_COLUMNS,'id,username,realname,gender,phone,email,to_char(createtime,\'yyyy-mm-dd hh24:mi:ss\') createtime,to_char(endtime,\'yyyy-mm-dd hh24:mi:ss\') endtime, state');//字段
	
	action.vars.put(action.V_MAX_LINE,'20');//每页显示多少条
	if(user.getRolekind()<3){
		action.vars.put(action.V_CONDITION,'where state!=2 order by id desc');//指定获取数据的表名
	}else{
		action.vars.put(action.V_CONDITION,'where state!=2 and userid = ' + user.getId() + ' order by id desc');//数据检索条件
	}
	
	
	//扩展字段
	action.vars.get(action.V_EXPEND_COLUMN).put('roles','select roleid,rolename from v_auth_role_users where userid=#id#');
	
	var state_cn = action.buildHashMap();
	//state输出：0.正常,1.试用 2.注销
	state_cn.put(action.V_MAPED_COLUMN,'state');//取state的值当key
	state_cn.put('0','正常');
	state_cn.put('1','试用');
	state_cn.put('2','注销');
	action.vars.get(action.V_MAP_COLUMN).put('state_cn',state_cn);

	var gender_cn = action.buildHashMap();
	//state输出：0.正常,1.试用 2.注销
	gender_cn.put(action.V_MAPED_COLUMN,'gender');//取state的值当key
	gender_cn.put('0','男');
	gender_cn.put('1','女');
	action.vars.get(action.V_MAP_COLUMN).put('gender_cn',gender_cn);
	
	action.vars.put(action.V_OUTPUT_FILE_FORMAT,'3');//以json输出
}